package com.cy.demo.controller;

import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

/*@Lazy*/
@RestController
@RequestMapping("/demo")
public class CRUDController {
    private AtomicLong count=new AtomicLong(1);
    public CRUDController(){
        System.out.println("创建对象");
    }
    @PutMapping
    public String doUpdate(@RequestBody Map map){
        return map.toString()+"is updated";
    }
    @PostMapping
    public String doCreate(@RequestBody Map map){
        return map.toString()+"is created";
    }

    @DeleteMapping("{id}")
    public String doDeleteById(@PathVariable Integer ...id){
        return Arrays.toString(id) +"is Deleted";
    }
    @GetMapping("{id}")
    public String doFindById(@PathVariable Integer id){
        String name = Thread.currentThread().getName();
        long l = count.getAndIncrement();
        return  name+":"+l+"find result by" +id;
    }
}
